function validateChk(frmName, action)
{	
	//alert(frmName);
	var frm_length=document.forms[frmName].elements.length;
	var chk_length=0;
	var chk_total=0;
  
  
	for(i=0;i<frm_length;i++)
	{
		if(document.forms[frmName].elements[i].type=="checkbox")
		{			
			if(document.forms[frmName].elements[i].checked  && document.forms[frmName].elements[i].name!="chkbox_n" )
				chk_length++;
			else
				chk_total++;
		}
	}

	if(chk_length==0)
	{
		if(chk_total==1)
		{
			showError("There is nothing to delete.",1000);
		}
		else
		{
			showError("Please select at least one checkbox.",1000);
		}
		
		return false;
	}
	else
	{
		 if (action == "activate") {
			$.confirm({
						'title' : 'DELETE CONFIRMATION',
						'message' : " <strong>YOU WANT TO ACTIVATE SELECTED RECORD (S) ?",
						'buttons' : {
							'Yes' : {
								'class' : 'special',
								'action' : function() {
									loading('Checking');
									$('#preloader').html('Activation in process...');
									jQuery('#pageAction').val('activate');
									document.forms[frmName].submit();
									return true;

								}
							},
							'No' : {
								'class' : ''
							}
						}
					});
			return false;
		}
		 if (action == "deactivate") {
				$.confirm({
							'title' : 'DELETE CONFIRMATION',
							'message' : " <strong>YOU WANT TO DEACTIVATE SELECTED RECORD (S) ?",
							'buttons' : {
								'Yes' : {
									'class' : 'special',
									'action' : function() {
										loading('Checking');
										$('#preloader').html('Deactivation in process...');
										jQuery('#pageAction').val('deactivate');
										document.forms[frmName].submit();
										return true;

									}
								},
								'No' : {
									'class' : ''
								}
							}
						});
				return false;
			} 	
		 if (action == "delete") {
				$.confirm({
							'title' : 'DELETE CONFIRMATION',
							'message' : " <strong>YOU WANT TO DELETE SELECTED RECORD (S) ?",
							'buttons' : {
								'Yes' : {
									'class' : 'special',
									'action' : function() {
										loading('Checking');
										$('#preloader').html('Deleting...');
										jQuery('#pageAction').val('delete');
										document.forms[frmName].submit();
										return true;

									}
								},
								'No' : {
									'class' : ''
								}
							}
						});
				return false;
			} 
	}
	return true;
}
